<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../currency/layer.html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <script type="text/javascript">
    var muneEdit ={
    	sumbit:function (){
    		_linwq_borderColor("mName");
    		_linwq_borderColor("mGrade");
    		_linwq_borderColor("mParentBtn");
    		_linwq_borderColor("mIconBtn");
    		_linwq_borderColor("mDescribe");
    		_linwq_borderColor("mUrl");
    		$("#msg").html('');
    		var param={
    				mId:'${mune.mId}',
    				mName:$("#mName").val(),
    				mGrade:$("#mGrade").val(),
    				mParent:$("#mParentBtn").val(),
    				mIcon:$("#mIconBtn").val(),
    				mDescribe:$("#mDescribe").val(),
    				mUrl:$("#mUrl").val()
    		}
    		if(_linwq_trim(param.mName+"")==''){
    			_linwq_borderColor("rName","red");
    			$("#msg").html("菜单名格式有误！");
    		}else if(_linwq_trim(param.rDescribe+"")==''){
    			_linwq_borderColor("mGrade","red");
    			$("#msg").html("菜单等级格式有误！");
    		}/* else if(_linwq_trim(param.mIcon+"")==''){
    			_linwq_borderColor("mIconBtn","red");
    			$("#msg").html("请选择图标！");
    		} */else if(_linwq_trim(param.mDescribe+"")==''){
    			_linwq_borderColor("mDescribe","red");
    			$("#msg").html("菜单描述格式有误！");
    		}else if(_linwq_trim(param.mIcon+"")==''){
    			_linwq_borderColor("mUrl","red");
    			$("#msg").html("菜单路径格式有误！");
    		}else{
    			var msg ;
    			var msg1 ;
    			if(param.rId){
    				msg = "确认保存修改的菜单信息？";//编辑
    				msg1 = "菜单信息修改成功";
    			}else{
    				msg = "确认新增改菜单信息？";//新增
    				msg1 = "菜单信息添加成功";
    			}
    			_linwq_confirm(msg,"确认","取消",function(){
	    			_linwq_ajax("/mune/muneSave.action",param,'text',function(data){
		    			if(data=="success"){
		    				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		    				parent.layer.msg(msg1,{icon:1});
		    				parent.layer.close(index); //再执行关闭   
		    			}else{
		    				var index = layer.getFrameIndex(window.name);
		    				layer.close(index);
		    				layer.msg(data,{icon:2});
		    			}
		    		}); 
    			});
    		}
    	}
    }	
    $(function(){
    		/* console.info($("#mIconBtn").next(".drop-list").children("ul").children("li")); */
    		$("#mIconBtn+.drop-list>ul>li").click(function(){
    			$("#mIconBtn").attr("class","btn btn-secondary dropdown-toggle " + $(this).attr("class"));
    		});
    })
	</script>
			<div class="page-wrap">
			<!--开始::内容-->
				<section class="page-hd">
					<header>
						<h2 class="title">表单结构展示</h2>
						<p class="title-description">
							两列式表单结构，一般针对产品详情，文章详情应用。
						</p>
					</header>
					<hr>
				</section>
					<div class="form-group-col-2">
						<div class="form-label">菜单名称：</div>
						<div class="form-cont">
							<input type="text" id="mName" placeholder="菜单名称..." value="${mune.mName }" class="form-control form-boxed">
						</div>
					</div>
					<div class="form-group-col-2">
						<div class="form-label">菜单等级：</div>
						<div class="form-cont">
							<input type="text" id="mGrade" placeholder="菜单等级..." value="${mune.mGrade }" class="form-control form-boxed">
						</div>
					</div>
					<div class="form-group-col-2">
						<div class="form-label">菜单父级：</div>
						<div class="form-cont">
							<div class="btn-drop-group">
								<button id="mParentBtn" class="btn btn-secondary dropdown-toggle" value="${mune.mParent}">${mune.parentName}</button>
								<div class="drop-list" >
									<ul >
										<li data-val="0">无父级菜单</li>
										<c:forEach items="${parentMune }" var="parent">
											<li data-val="${parent.mId}">${parent.mName}</li>
										</c:forEach>
									</ul>
								</div>
							</div>
						</div>
					</div>
					<div class="form-group-col-2">
						<div class="form-label">图标：</div>
						<div class="form-cont">
							<div class="btn-drop-group">
								<button id="mIconBtn" class="btn btn-secondary dropdown-toggle ${mune.mIcon }" value="${mune.mIcon }"></button>
								<div class="drop-list" >
									<ul >
										<li >无图标></li>
										<c:forEach items="${iconList }" var="icon">
											<li data-val="${icon.iconVal}" class="${icon.iconVal}"></li>
										</c:forEach>
									</ul>
								</div>
							</div>
						</div>
					</div>
					<div class="form-group-col-2">
						<div class="form-label">菜单描述：</div>
						<div class="form-cont">
							<textarea id="mDescribe" class="form-control form-boxed" style="resize:none;">${mune.mDescribe}</textarea>
						</div>
					</div>
					<div class="form-group-col-2">
						<div class="form-label">地址：</div>
						<div class="form-cont">
							<input type="text" id="mUrl" placeholder="" value="${mune.mUrl }" class="form-control form-boxed">
						</div>
					</div>
					<div class="form-group-col-2">
						<div class="form-label"></div>
						<div class="form-cont">
							<input type="button" class="btn btn-primary" value="提交表单" onclick="muneEdit.sumbit()"/>
							<span style="color: red;" id="msg"></span>
						</div>
					</div>
				<!--开始::结束-->
			</div>
